package com.huat.sportmeetingmanagement.entity;

import com.google.gson.annotations.Expose;
import com.huat.sportmeetingmanagement.entity.enumEntity.ErrorListEnum;

/**
 * @author chenlixian
 * @description TODO 封装返回类
 * @date 2020/3/15 17:14
 */
public class GeneralVO<T> extends BaseVo {
    @Expose
    private T body;

    public GeneralVO() {
    }

    public GeneralVO(int code, String msg, T body) {
        this.setCode(code);
        this.setMsg(msg);
        this.setBody(body);
    }

    public GeneralVO(ErrorListEnum listEnum, T body) {
        this.setCode(listEnum.getKey());
        this.setMsg(listEnum.getValue());
        this.setBody(body);
    }

    public T getBody() {
        return this.body;
    }

    public void setBody(T t) {
        this.body = t;
    }

    public String toString() {
        String result = '{' + "\"code\":" + this.getCode() + ',' + "\"msg\":\"" + this.getMsg() + "\"," + "\"body\":" + this.getBody() + '}';
        return result;
    }
}